package me.zhengjie.modules.forecast.dto;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.heshuo.amm.model.FlightConfig;
import com.heshuo.amm.model.PathsFromFlightConfig;
import com.heshuo.amm.service.FlightFile;

public class FlightConfigDTO extends FlightConfig {

	@Override
	public List<String> getPublishedCenter() {
		List<String> releaseCenters = (List<String>) getContentMap().get(FlightFile.PUBLISHED_CENTER);
		return releaseCenters;
	}

	@Override
	public List<String> getImportantWeatherForecastMapHeight() {
		List<String> list = (List<String>) getContentMap().get(FlightFile.IMPORTTANT_WEATHER_FORECAST_MAP);
		return list;
	}

	@Override
	public List<String> getArea() {
		List<String> list = (List<String>) getContentMap().get(FlightFile.AREA);
		return list;
	}

	@Override
	public List<String> getHightList() {
		List<String> list = (List<String>) getContentMap().get(FlightFile.HEIGHT);
		return super.getHightList();
	}

	@Override
	public List<String> getAgingList() {
		List<String> list = (List<String>) getContentMap().get(FlightFile.AGING);
		return list;
	}

	@Override
	public List<Integer> getEffectiveTime() {
		List<Integer> list = (List<Integer>) getContentMap().get(FlightFile.EFFECTOVE_TIME);
		return list;
	}

	@Override
    public List<List<String>> getFileNames() {
        List<List<String>> retList = new ArrayList<List<String>>();
        List<String> publishedCenterList = getPublishedCenter(); // 发布中心

        List<String> areaList = getArea(); // 区域代码A1

        List<String> agings = getAgingList(); // 时效 A2

        List<Integer> effectiveTimeList = getEffectiveTime(); // 有效时间 G

        List<String> hightList = getHightList(); // 高度层
        Date now = new Date();// 当前时间
        for (String center : publishedCenterList) {
            for (String area : areaList) {
                for (String hight : hightList) {
//                    for (Integer effectiveTime : effectiveTimeList) {
                	for (Object et : effectiveTimeList) {
                		Integer effectiveTime = Integer.valueOf(et.toString());
                        List<String> tempList = new ArrayList<String>();
                        for (String aging : agings) {
                            Integer agingNumber = Integer.parseInt(aging);
                            Long publishTime = getPublishTime(now,
                                    effectiveTime * 6, agingNumber);
                            Date tempDate = new Date(publishTime);
                            SimpleDateFormat sdf = new SimpleDateFormat("HH");
                            String hour = sdf.format(tempDate);
                            PathsFromFlightConfig path = new PathsFromFlightConfig(
                                    center, area, hight, aging, hour, tempDate);
                            String tempString = path.getFileNameList();
                            if (tempString != null && !tempString.isEmpty()) {
                                tempList.add(tempString);
                            }
                        }
                        if (!tempList.isEmpty()) {
                            retList.add(tempList);
                        }
                    }
                }
            }
        }
        return retList;
    }

}
